package com.ljh.xml;

import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.Node;
import org.dom4j.io.SAXReader;

import java.util.List;

/**
 * @Author: lu
 * @Date: 2021/12/29 22:30
 * @Description:
 */
public class TestBooks {
    public static void main(String[] args) throws DocumentException {
        SAXReader sr = new SAXReader();
        Document document = sr.read("E:\\jdbc_task\\work\\src\\com\\ljh\\xml\\books.xml");
        List<Node> list = document.selectNodes("/books/book//*");
        for (Node node:list) {
            System.out.println(node.getName()+" = "+node.getText());
        }
    }
}
